﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common.Error
{
    public class ErrorHelper
    {

        #region HTTP 401 Unauthorized

        /// <summary>
        /// Invalid Consumer Key
        /// </summary>
        public static ErrorType INVALID_CONSUMER_KEY
        {
            get { return new ErrorType("40101", "Invalid Consumer Key"); }
        }

        /// <summary>
        /// Invalid Consumer Key/Secret
        /// </summary>
        public static ErrorType INVALID_CONSUMER_KEY_SECRET
        {
            get { return new ErrorType("40102", "Invalid Consumer Key/Secret"); }
        }


        /// <summary>
        /// Invalid / expired Token
        /// </summary>
        public static ErrorType INVALID_EXPIRED_TOKEN
        {
            get { return new ErrorType("40103", "Invalid / expired Token"); }
        }

        /// <summary>
        /// Invalid signature
        /// </summary>
        public static ErrorType INVALID_SIGNATURE
        {
            get { return new ErrorType("40104", "Invalid signature"); }
        }

        /// <summary>
        /// Invalid / used nonce
        /// </summary>
        public static ErrorType INVALID_USED_NONCE
        {
            get { return new ErrorType("40105", "Invalid / used nonce"); }
        }

        #endregion

        #region HTTP 400 Bad Request

        /// <summary>
        /// Unsupported parameter
        /// </summary>
        public static ErrorType UNSUPPORTED_PARAMETER
        {
            get { return new ErrorType("40001", "Unsupported parameter"); }
        }

        /// <summary>
        /// Unsupported signature method
        /// </summary>
        public static ErrorType UNSUPPORTED_SIGNATURE_METHOD
        {
            get { return new ErrorType("40002", "Unsupported signature method"); }
        }

        /// <summary>
        /// Missing required parameter
        /// </summary>
        public static ErrorType MISSING_REQUIRED_PARAMETER
        {
            get { return new ErrorType("40003", "Missing required parameter"); }
        }

        /// <summary>
        /// Duplicated OAuth Protocol Parameter 
        /// </summary>
        public static ErrorType DUPLICATED_OAUTH_PROTOCOL_PARAMETER
        {
            get { return new ErrorType("40004", "Duplicated OAuth Protocol Parameter"); }
        }

        #endregion

        public static ErrorType NewError(string error_code, string error_message)
        {
            return new ErrorType(error_code, error_message);
        }

    }


    public class ErrorType
    {
        private string error_code;
        private string error_message;

        public string ERROR_CODE
        {
            get { return this.error_code; }
            set { this.error_code = value; }
        }
        public string ERROR_MESSAGE
        {
            get { return this.error_message; }
            set { this.error_message = value; }
        }

        public ErrorType(string error_code, string error_message)
        {
            this.error_code = error_code;
            this.error_message = error_message;
        }

    }
}
